import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class TestSynVM {

    ///**
    // *
    // */
    //public void test(){
    //    //synchronized (TestJVM.class){
    //    //    System.out.println("TestJVM.class");
    //    //}
    //    synchronized (this){
    //        System.out.println("this");
    //    }
    //}

    public static void main(String[] args) {
        //Map hash = new HashMap<>();
        //
        //long startTime =System.currentTimeMillis();
        //for (int i = 0; i < 1000001; i++) {
        //    hash.put(i+"",i+"");
        //}
        //long endTime =System.currentTimeMillis();
        //System.out.println((endTime-startTime)/1000);

        long startTime = System.currentTimeMillis();

        List<String> list = new LinkedList<>();
        for (int i = 0; i < 1000001; i++) {
            list.add(getRandomChar());
        }
        list.add("北京大学人民医院");
        long endTime = System.currentTimeMillis();

        System.out.println((endTime - startTime));

        startTime = System.currentTimeMillis();

        for (int i = 0; i < list.size(); i++) {
            if ("ABC北京大学人民医院SDS".contains(list.get(i))) {
                System.out.println(list.get(i));
            }
        }
        endTime = System.currentTimeMillis();
        System.out.println((endTime - startTime));
    }

    private static String getRandomChar() {
        String str = "";
        int hightPos; //
        int lowPos;
        Random random = new Random();
        hightPos = (176 + Math.abs(random.nextInt(39)));
        lowPos = (161 + Math.abs(random.nextInt(93)));
        byte[] b = new byte[4];
        b[0] = (Integer.valueOf(hightPos)).byteValue();
        b[1] = (Integer.valueOf(lowPos)).byteValue();
        b[2] = (Integer.valueOf(hightPos)).byteValue();
        b[3] = (Integer.valueOf(lowPos)).byteValue();
        try {
            str = new String(b, "GBK");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            System.out.println("错误");
        }
        return str;
    }
}



